﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="EnvironmentalMonitor.WebApplication.Environmental.Detector.List" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <% = this.ReferencejQueryCss %>
    <% = this.ReferencejQueryJavascript %>
    <style type="text/css">
        html, body
        {
            margin: 0px;
            padding: 0px;
            height: 100%;
            overflow: hidden;
        }
        #dialog_form
        {
            margin: 0;
            padding: 10px 30px;
        }
        .form_title
        {
            font-size: 14px;
            font-weight: bold;
            color: #666;
            padding: 5px 0;
            margin-bottom: 10px;
            border-bottom: 1px solid #ccc;
        }
        .form_item
        {
            margin-bottom: 5px;
        }
        .form_item label
        {
            display: inline-block;
            width: 120px;
        }
        .form_input
        {
            width: 200px;
        }
    </style>
    <script type="text/javascript">
        var url = '<% = this.SaveJsonUrl %>';
        var deleteUrl = '<% = this.DeleteJsonUrl %>';

        function newModule() {
            $('#list_data_grid_dialog').dialog('open').dialog('setTitle', '新增');
            $('#dialog_form').form('clear');
            var module = initNewModule();
            $('#dialog_form').form('load', module);
        };

        function editModule() {
            var row = $('#list_data_grid').datagrid('getSelected');
            if (row) {
                $('#list_data_grid_dialog').dialog('open').dialog('setTitle', '修改');
                $('#dialog_form').form('clear');
                $('#dialog_form').form('load', row);
                initEditModule();
            }
        };

        function deleteModule() {
            var row = $('#list_data_grid').datagrid('getSelected');
            if (row) {
                if (confirm('是否删除该数据？')) {
                    var ajaxDeleteUrl = deleteUrl + '?guid=' + row.Guid;
                    $.ajax({
                        type: 'POST',
                        url: ajaxDeleteUrl,
                        success: function (data, textStatus, jqXHR) {
                            var result = eval('(' + data + ')');
                            $.messager.show({
                                title: '消息',
                                msg: result.msg
                            });
                            $('#list_data_grid').datagrid('reload');
                        }
                    });
                }
                else {
                    return false;
                }
            }
        };

        function saveModule() {
            $('#dialog_form').form('submit', {
                url: url,
                onSubmit: function () {
                    var result = validateModule();
                    if (result) {
                        result = $(this).form('validate');
                    }
                    return result;
                },
                success: function (result) {
                    var result = eval('(' + result + ')');
                    if (result.success) {
                        $('#list_data_grid_dialog').dialog('close');
                        $('#list_data_grid').datagrid('reload');
                    } else {
                        $.messager.show({
                            title: '错误',
                            msg: result.msg
                        });
                    }
                }
            });
        };

        function initNewModule() {
            return { "Guid": null, "InsertUserId": null, "InsertTime": null, "UpdateUserId": null, "UpdateTime": null, "Remark": null, "Validity": true, "MachineId": null, "DetectorTypeId": null, "Serial": 1024 };
        };

        function initEditModule() {
        };

        function validateModule() {
            var result = true;

            return result;
        };
    </script>
</head>
<body>
    <div style="width: 100%; height: 100%">
        <table id="list_data_grid" title="<% = this.Description %>管理" class="easyui-datagrid"
            style="width: 100%; height: 100%" url="<% = this.ListJsonUrl %>" toolbar="#list_data_grid_toolbar"
            pagination="true" rownumbers="true" fitcolumns="true" singleselect="true" fit="true"
            pagelist="[<% = int.MaxValue %>]">
            <thead>
                <tr>
                    <th field="RoomName">
                        机房
                    </th>
                    <th field="MachineName">
                        设备
                    </th>
                    <th field="Serial">
                        序号
                    </th>
                    <th field="DetectorTypeName">
                        探头类型
                    </th>
                    <th field="DetectorTypeCode">
                        探头类型代码
                    </th>
                    <th field="DetectorTypeTypeText">
                        探头分类
                    </th>
                    <th field="DetectorTypeThreshold">
                        探头阀值
                    </th>
                    <th field="DetectorTypeMinimum">
                        探头最小值
                    </th>
                    <th field="DetectorTypeMaximum">
                        探头最大值
                    </th>
                    <th field="Remark">
                        备注
                    </th>
                </tr>
            </thead>
        </table>
        <div id="list_data_grid_toolbar">
            <a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="javascript:newModule()">
                新增<% = this.Description %></a> <a href="#" class="easyui-linkbutton" iconcls="icon-edit"
                    plain="true" onclick="javascript:editModule()">修改<% = this.Description %></a><a href="#"
                        class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="javascript:deleteModule()">删除<% = this.Description %></a>
        </div>
        <div id="list_data_grid_dialog" class="easyui-dialog" style="width: 640px; height: 360px;
            padding: 10px 20px" closed="true" buttons="#list_data_grid_dialog_buttons">
            <div class="form_title">
                <% = this.Description %>信息</div>
            <form id="dialog_form" method="post">
            <div class="form_item">
                <label>
                    类型：</label>
                <input type="hidden" name="Guid" />
                <input class="easyui-combobox form_input" id="DetectorTypeId" name="DetectorTypeId"
                    data-options="valueField:'Guid',textField:'Name',url:'<% = this.DetectorTypeComboboxJsonUrl %>'" />
            </div>
            <div class="form_item">
                <label>
                    序号：</label>
                <input name="Serial" value="1024" class="easyui-numberspinner form_input" required="required"
                    data-options="min:1,max:<% = int.MaxValue %>,editable:true">
            </div>
            <div class="form_item">
                <label>
                    备注：</label>
                <textarea name="Remark" class="form_input" rows="3"></textarea>
            </div>
            </form>
        </div>
        <div id="list_data_grid_dialog_buttons">
            <a href="#" class="easyui-linkbutton" iconcls="icon-ok" onclick="javascript:saveModule()">
                保存</a> <a href="#" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#list_data_grid_dialog').dialog('close')">
                    取消</a>
        </div>
    </div>
</body>
</html>
